//=============================================================================

#ifndef APACKET_H
  #define APACKET_H

//=============================================================================

#include "doCommon.h"

//=============================================================================

enum aptType
{
  PAK_NULL = 0,
  PAK_INI,
  PAK_CLS_CON,
  PAK_ADD_MAGE,
};

//=============================================================================
// Admit that first byte of received data it's a type of packet. It's cutted
// from data, but in length it taked into account with 4 length bytes

class aPacket
{
  public:
    inline char* apGetData() const            {return data;}
    inline unsigned long apGetLength() const  {return length;}
    inline char apGetType() const             {return type;}

    aPacket();
    aPacket(aptType t);
    aPacket(char* in);
    aPacket(const aPacket& p);
      void apClearPacket();
      void apChewPacket(char* in = 0);
      virtual void apApartPacket() {};

      const aPacket& operator=(const aPacket& p);

    virtual ~aPacket();

  protected:
      virtual void apPreparePacket() {};

  protected:
    char* data;
    unsigned long length;
    unsigned char type;
    
    const size_t floatSize;
    const size_t longSize;
    const size_t boolSize;
    const size_t charSize;
};

//=============================================================================

#endif

//=============================================================================
